<?php 

Class proModel extends AppModel
{
	
	
	public function get_pro($id)
	{
		$sql="SELECT a.*,b.middle_pic,b.original_pic FROM ".$this->table('product')." as a,".$this->table('product_img')." as b WHERE a.id=b.product_id AND  a.id = '".$id."' ORDER BY b.id ASC";
			
		$result=$this->getRow($sql);
		
		$sql="SELECT small_pic,middle_pic,original_pic FROM ".$this->table('product_img')." WHERE product_id = '".$id."' ORDER BY id ASC";
		$gallery=$this->getAll($sql);
		
		if($result)
		{
			$result['gallery']=$gallery;
			return $result;
		}
		else
		{
			return $result=array();
		}
	}
	
	public function pro_list($page=1,$cat_id)
	{
		$listPage=array('data'=>'','pageLink'=>'');
		
		$result=$this->get_page("id,title,thumb",$this->table('product'),' cat_id='.$cat_id,$page,'10');
		$listPage['pagelink']=$this->getpagelink();
		$listPage['data']=$result;
		
		
		return $listPage;
	}
	
	
}